<template>
  <div>
    <h1>商家审核管理</h1>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="merchantId"
        label="id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="userId"
        label="用户的id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="merchantName"
        label="商店名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="licenseImage"
        label="营业执照">
        <template slot-scope="scope">
          <el-image :src="scope.row.licenseImage"></el-image>
        </template>
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <span v-if="scope.row.merchantStatus==0">
            <el-button @click="MerchantUpdate(scope.row.merchantId,scope.row.userId,1)">审核通过</el-button>
            <el-button @click="MerchantUpdate(scope.row.merchantId,scope.row.userId,2)">审核未通过</el-button>
          </span>
          <span v-if="scope.row.merchantStatus==1">审核已通过</span>
          <span v-if="scope.row.merchantStatus==2">审核未通过</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>


<script>
  import { MerchantSelect,userMerchantid} from '@/api/users'
  export default {
    data() {
      return {
        tableData: []
      }
    },
    mounted(){
      this.MerchantSelect()
    },
    methods:{
      MerchantSelect(){
        MerchantSelect().then((res)=>{
          console.log(res.data)
          this.tableData=res.data
        })
      },
      MerchantUpdate(row1,row2,row3){
        userMerchantid(row1,row2,row3).then((res)=>{
          this.MerchantSelect()
        })
      }
    }
  }
</script>

<style scoped></style>
